package com.lzzy.dao;


import com.lzzy.model.domain.Article;
import com.lzzy.model.domain.Comment;
import com.lzzy.model.domain.Friends;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import javax.transaction.Transactional;
import java.util.List;

public interface CommentRepository extends JpaRepository<Comment, Integer> {

    //根据articleId查询评论
    public List<Comment> findByArticleId(Integer id);



    // 根据id删除对应评论
    @Transactional
    @Modifying
    @Query("DELETE FROM t_comment c WHERE c.id= ?1")
    public int deleteDiscuss(Integer id);

    @Override
    public List<Comment> findAll();



}
